const app=getApp()
let titles=[]
Page({
  data:{
    total:0,
    current:1,
    
  },
  onLoad() {
    
    let arr=wx.getStorageSync('cuoti')
    console.log('错题',arr)
    if(arr && arr.length>0){
      titles=arr
      
    }
    console.log('错题集',titles)
    this.setData({
        subject:titles[0],
        total:titles.length

      })
    //console.log("全局变量", app.globalData.globalErrorOptions)
  },
  pre(){
    if(this.data.current - 1<=0){
      wx.showToast({
        icon:'error',
        title: '已经是第一个了',
      })
      
    }
    else{
      this.setData ({
      current:this.data.current - 1,
      subject:titles[this.data.current - 2]
      })
    }
  },
  next(){
    
    if(this.data.current + 1>titles.length){
      wx.showToast({
        icon:'error',
        title: '已经是最后一道错题了',
      })
      
    }
    else{
      this.setData ({
      current:this.data.current + 1,
      subject:titles[this.data.current]
      })
    }

  },
  tuichu(){
    
    wx.navigateTo({
      url: '../home/home',
    })
    
     
  }

  
})